// import { listAccount, getAccount, delAccount, addAccount, updateAccount } from "@/api/media/mediaManage";

export const ExecuteFunc = {
  kuaishou:{
        //获取同城视频数据
        getTongcheng:`fetch("https://www.kuaishou.com/graphql", {
        "headers": {
          "content-type": "application/json",
        },
        "body": JSON.stringify({
          "operationName": "sameCityDataQuery",
          "query": "fragment photoContent on PhotoEntity {\\n id\\n duration\\n caption\\n originCaption\\n likeCount\\n viewCount\\n commentCount\\n realLikeCount\\n coverUrl\\n photoUrl\\n photoH265Url\\n manifest\\n manifestH265\\n videoResource\\n coverUrls {\\n url\\n __typename\\n }\\n timestamp\\n expTag\\n animatedCoverUrl\\n distance\\n videoRatio\\n liked\\n stereoType\\n profileUserTopPhoto\\n musicBlocked\\n __typename\\n}\\n\\nfragment feedContent on Feed {\\n type\\n author {\\n id\\n name\\n headerUrl\\n following\\n headerUrls {\\n url\\n __typename\\n }\\n __typename\\n }\\n photo {\\n ...photoContent\\n __typename\\n }\\n canAddComment\\n llsid\\n status\\n currentPcursor\\n tags {\\n type\\n name\\n __typename\\n }\\n __typename\\n}\\n\\nfragment photoResult on PhotoResult {\\n result\\n llsid\\n expTag\\n serverExpTag\\n pcursor\\n feeds {\\n ...feedContent\\n __typename\\n }\\n webPageArea\\n __typename\\n}\\n\\nquery sameCityDataQuery($pcursor: String, $semKeyword: String, $semCrowd: String, $utmSource: String, $utmMedium: String, $page: String) {\\n sameCityData(pcursor: $pcursor, semKeyword: $semKeyword, semCrowd: $semCrowd, utmSource: $utmSource, utmMedium: $utmMedium, page: $page) {\\n ...photoResult\\n __typename\\n }\\n}\\n",
          "variables": {semKeyword: "", semCrowd: "", utmSource: "", utmMedium: "", page: "nearby",pcursor:"103320884018:30:28.1975:112.968307"},
      }),
        "method": "POST",
      }).then(res=> {return res.text()}).then(res=> {return res}).catch(err=>{return err})`
      },
   //视频号小店
    sphxd:{
      getLoginStatus:'window.__INITIAL_STATE__ ? true : false', //获取账号登录状态
      getUserInfo:"window.__INITIAL_STATE__.userInfo", //获取用户数据
    },
    //微信公众号
    wxgzh: {
      getLoginStatus:'window.wx.commonData.uin ? true : false', //获取账号登录状态
      getLocalstatus: "/token=(\\d+)($|&)/.exec(location.href)?true:false",//获取当前连接
      getUserInfo: `fetch("https://mp.weixin.qq.com").then(res=>res.text()).then(data=>{
                    const avatar = /wx.cgiData.head_img = "(.*?)"/.exec(data)[1] || ''
                    let uin = /uin: "(.*?)"/.exec(data)[1] || ''
                    let uin_base64 = /uin_base64: "(.*?)"/.exec(data)[1] || ''
                    let user_name = /user_name: "(.*?)"/.exec(data)[1] || ''
                    let nick_name = /nick_name: "(.*?)"/.exec(data)[1] || ''
                    let realnameType = /realnameType: '(.*?)'/.exec(data)[1] || '' //主体类型
                    let isPersonVerify = /isPersonVerify: '(.*?)'/.exec(data)[1] || '' //是否个人认证
                    return {avatar,uin,uin_base64,user_name,nick_name,realnameType,isPersonVerify}
                    }).catch(err=>{console.log(err)})`
    },
  //微信小程序
    wxxcx: {
        getLoginStatus:'window.__INITIAL_STATE__ ? true : false', //获取账号登录状态
        getLocalstatus: "/token=(\\d+)($|&)/.exec(location.href)?true:false",//获取当前连接
        getUserInfo: `fetch("https://mp.weixin.qq.com").then(res=>res.text()).then(data=>{
                    let userinfo = /userInfo:(.*)}/.exec(data)[1]+"}"
                    const UserinfoDict = JSON.parse(userinfo)
                    let appid = UserinfoDict.appid;
                    let fakeId = UserinfoDict.fakeId;
                    let fakeIdBase64 = UserinfoDict.fakeIdBase64;
                    let avatar = UserinfoDict.iconUrl;
                    let mediaTicket = UserinfoDict.mediaTicket;
                    let nickname = UserinfoDict.nickName;
                    let openid = UserinfoDict.openid;
                    let userName = UserinfoDict.userName;
                    return {appid,fakeId,fakeIdBase64,avatar,mediaTicket,nickname,openid,userName}
                    }).catch(err=>{console.log(err)})`
    },
    //微信视频号
    wxsph: {
        getLoginStatus: `fetch("https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_finder_list", {
            "headers": {
              "content-type": "application/json",
            },
            "body":JSON.stringify({"timestamp":+ new Date(),"_log_finder_id":null,"rawKeyBuff":null,"pluginSessionId":null,"scene":1}),
            "method": "POST",
            "mode": "cors"
          }).then(res=>{return res.json()}).then(res=>{
              if(res.errCode==0){return true};return false})`,
        getLocalstatus: `fetch("https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_finder_list", {
            "headers": {
              "content-type": "application/json",
            },
            "body":JSON.stringify({"timestamp":+ new Date(),"_log_finder_id":null,"rawKeyBuff":null,"pluginSessionId":null,"scene":1}),
            "method": "POST",
            "mode": "cors"
          }).then(res=>{return res.json()}).then(res=>{
              if(res.errCode==0){return true};return false})`,
        getUserInfo: `fetch("https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_finder_list", {
            "headers": {
              "content-type": "application/json",
              "x-wechat-uin": "0000000000"
            },
            "body":JSON.stringify({"timestamp":+ new Date(),"_log_finder_id":null,"rawKeyBuff":null,"pluginSessionId":null,"scene":1}),
            "method": "POST",
            "mode": "cors"
          }).then(res=>{return res.json()}).then(res=>{return res.data.finderList }).catch(err=>{return err})`,
        setUserLogin: `fetch("https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_set_finder", {
            "headers": {
              "content-type": "application/json",
              "x-wechat-uin": "0000000000"
            },
            "body": JSON.stringify({
              "finderUsername": "finderUsernameReplace",
              "timestamp": + new Date(),
              "_log_finder_id": "finderUsernameReplace",
              "rawKeyBuff": "",
              "pluginSessionId": null,
              "scene": 1
          }),
            "method": "POST",
          }).then(res=> {return res.text()}).then(res=> {return res}).catch(err=>{return err})`
    },
    //抖音
    douyin: {
      getLoginStatus: `fetch("https://creator.douyin.com/web/api/media/user/info/", {
          "headers": {
            "accept": "application/json, text/plain, */*",
            "accept-language": "zh-CN,zh;q=0.9",
            "cache-control": "no-cache",
            "pragma": "no-cache",
            "sec-ch-ua": "\\"Google Chrome\\";v=\\"105\\", \\"Not)A;Brand\\";v=\\"8\\", \\"Chromium\\";v=\\"105\\"",
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": "\\"Windows\\"",
            "sec-fetch-dest": "empty",
            "sec-fetch-mode": "cors",
            "sec-fetch-site": "same-origin"
          },
          "referrer": "https://creator.douyin.com/creator-micro/home",
          "referrerPolicy": "strict-origin-when-cross-origin",
          "body": null,
          "method": "GET",
          "mode": "cors",
          "credentials": "include"
        }).then(res=>res.json()).then(res=>{ return res.status_code !=0 ?false : true }).catch(err=>err)`,
          getLocalstatus: `fetch("https://creator.douyin.com/web/api/media/user/info/", {
          "headers": {
            "accept": "application/json, text/plain, */*",
            "accept-language": "zh-CN,zh;q=0.9",
            "cache-control": "no-cache",
            "pragma": "no-cache",
            "sec-ch-ua": "\\"Google Chrome\\";v=\\"105\\", \\"Not)A;Brand\\";v=\\"8\\", \\"Chromium\\";v=\\"105\\"",
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": "\\"Windows\\"",
            "sec-fetch-dest": "empty",
            "sec-fetch-mode": "cors",
            "sec-fetch-site": "same-origin"
          },
          "referrer": "https://creator.douyin.com/creator-micro/home",
          "referrerPolicy": "strict-origin-when-cross-origin",
          "body": null,
          "method": "GET",
          "mode": "cors",
          "credentials": "include"
        }).then(res=>res.json()).then(res=>{ return res.status_code !=0 ?false : true }).catch(err=>err)`,
        getUserInfo: `fetch("https://creator.douyin.com/web/api/media/user/info/", {
            "headers": {
              "accept": "application/json, text/plain, */*",
              "accept-language": "zh-CN,zh;q=0.9",
              "cache-control": "no-cache",
              "pragma": "no-cache",
              "sec-ch-ua": "\\"Google Chrome\\";v=\\"105\\", \\"Not)A;Brand\\";v=\\"8\\", \\"Chromium\\";v=\\"105\\"",
              "sec-ch-ua-mobile": "?0",
              "sec-ch-ua-platform": "\\"Windows\\"",
              "sec-fetch-dest": "empty",
              "sec-fetch-mode": "cors",
              "sec-fetch-site": "same-origin"
            },
            "referrer": "https://creator.douyin.com/creator-micro/home",
            "referrerPolicy": "strict-origin-when-cross-origin",
            "body": null,
            "method": "GET",
            "mode": "cors",
            "credentials": "include"
          }).then(res=>res.json()).then(res=> res.user).catch(err=>err)`
    },
    // 抖店
    "1616066134496858114": {
      getLocalstatus: `fetch("https://fxg.jinritemai.com/byteshop/loginv2/getallshop?loginSourceV2=doudian_pc_v2", {
        "headers": {
          "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
          "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
          "cache-control": "max-age=0",
          "sec-fetch-dest": "document",
          "sec-fetch-mode": "navigate",
          "sec-fetch-site": "none",
          "sec-fetch-user": "?1",
          "upgrade-insecure-requests": "1"
        },
        "referrerPolicy": "strict-origin-when-cross-origin",
        "body": null,
        "method": "GET",
        "mode": "cors",
        "credentials": "include"
      }).then(res=>res.json()).then(res=> {return res.code==0? true:false}).catch(err=>err)`,
      getUserInfo: `fetch("https://fxg.jinritemai.com/byteshop/loginv2/getallshop?loginSourceV2=doudian_pc_v2", {
        "headers": {
          "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
          "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
          "cache-control": "max-age=0",
          "sec-fetch-dest": "document",
          "sec-fetch-mode": "navigate",
          "sec-fetch-site": "none",
          "sec-fetch-user": "?1",
          "upgrade-insecure-requests": "1"
        },
        "referrerPolicy": "strict-origin-when-cross-origin",
        "body": null,
        "method": "GET",
        "mode": "cors",
        "credentials": "include"
      }).then(res=>res.json()).then(res=> res.data).catch(err=>err)`
  },

    wxsphjr: {
       getLoginStatus: `fetch("https://channels.weixin.qq.com/promote/api/web/promotion/get-feed-promotion-user-profile", {
              "headers": {
                "content-type": "application/json",
              },
              "referrer": "https://channels.weixin.qq.com/promote/pages/platform/login",
              "body": "{}",
              "method": "POST",
            }).then(res=>res.json()).then(r=>{
              return r.data ? true : false;
            })`,
        getLocalstatus: `fetch("https://channels.weixin.qq.com/promote/api/web/promotion/get-feed-promotion-user-profile", {
              "headers": {
                "content-type": "application/json",
              },
              "referrer": "https://channels.weixin.qq.com/promote/pages/platform/login",
              "body": "{}",
              "method": "POST",
            }).then(res=>res.json()).then(r=>{
              return r.data ? true : false;
            })`,
     getUserInfo: `fetch("https://channels.weixin.qq.com/promote/api/web/promotion/get-feed-promotion-user-profile", {
          "headers": {
            "content-type": "application/json",
          },
          "referrer": "https://channels.weixin.qq.com/promote/pages/platform/login",
          "body": "{}",
          "method": "POST",
        }).then(res=>res.json()).then(r=>{
          return r.data.accountInfo
          })`
        },
    xhs: {
        getLoginStatus: ` fetch("https://creator.xiaohongshu.com/api/galaxy/user/info", {
        "body": null,
        "method": "GET",
      }).then(res=>res.json()).then(res=>{ return res.result !=0 ? false :true})`,
        getLocalstatus: ` fetch("https://creator.xiaohongshu.com/api/galaxy/user/info", {
        "body": null,
        "method": "GET",
      }).then(res=>res.json()).then(res=>{ return res.result !=0 ? false :true})`,
        getUserInfo: `fetch("https://creator.xiaohongshu.com/api/galaxy/user/info", {
        "body": null,
        "method": "GET",
      }).then(res=>res.json()).then(res=>{ return res.data})`
    },
    //获取抖音直播源
    douyinzhibo:{
      getLink:"__LIVING_PLAYER__.getPlayer().config.url"
    },
}

export function getTimeSecond(time) {
    // 转换为式分秒
    let h = parseInt(String(time / 60 / 60 % 24))
    let m = parseInt(String(time / 60 % 60))
    let s = parseInt(String(time % 60))
    return `${h > 0 ? h + '时' : ''}${m}分${s}秒`
}

//将字节转成大小M
export function getFolesize(size) {
    return size > 1024 ? (size / 1024 / 1024).toFixed(2) + "M" : size == undefined ? '1M' : size;
}

//将时间戳转为时间
export function filterTime(time) {
    const date = new Date(time * 1000)
    const Y = date.getFullYear();
    const M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
    const D = date.getDate();
    const h = date.getHours();
    const m = date.getMinutes();
    const s = date.getSeconds();
    return `${Y}-${M}-${D} ${h}:${m}:${s}`
}

